function  [bdrawp,m1,CC1]=drawnorm(y,x,prm,prprec,sig);
%function [bdrawp,m1,CC1]=drawnorm(y,x,prm,prprec,sig); 
% Draw Coefficients from a Normal Dustribution when prior is also :
%      Normal( prm, prprec^(-1) )  
%      prprec is the precision  
% y      (Txn) 
% x      (TxK)  
% Prm    (Kx1)  Prior Mean 
% prprec (KxK)  Prior Precision
% Sig    (1x1)
%
% bdrawp (Kx1)is the draw from the posterior normal as a row vector 
% m1     (Kx1) is the posterior mean 
% CC1     (KxK) is the Cholelsky of the posterior variance 
%         V1= CC1'*CC1  
[ty,ny]=size(y); 
[tx,nx]=size(x); 
nk=length(prm);
if tx~=ty
    error('Not equal number of observations in drawcoef'); 
end; 
V1=( prprec+( (1/sig)*(x'*x) ) ) \ eye(nk) ; % Posterior Variance  
m1=V1*(prprec*prm + (1/sig)*(x'*y) );        % Posterior Mean  
CC1=chol(V1); 
bdraw=m1+CC1'*randn(nk,1);
bdrawp=bdraw'; 
m1=m1'; 